var express = require('express');

var app = express();

var bodyParser = require('body-parser');  //post请求中间件

var cookieParser = require('cookie-parser');  //cookie会话中间件

var user = require('./routes/user')

var home = require('./routes/home')

var mock = require('./mock/mock')

app.use(bodyParser());

app.use(express.static(__dirname + '/public'));

app.set('view engine','jade')

app.set('views',__dirname+'/views')

app.set('port',process.env.PORT || 5000);


// app.get('/login',function (req,res) {
// 	res.render('login',{user:'failed'})
// })

app.use('/chartRoom/user',user)


app.use('/wechat_app',mock)
// app.use('/home',home)

// app.get('/register',function (req,res) {
// 	res.render('register',{
// 		user:'failed'
// 	})
// })

// app.get('/login',function (req,res) {
// 	res.render('login',{user:'failed'})
// })

// app.get('/forget',function (req,res) {
// 	res.render('forget',{})
// })
// 
// 



app.use(function (err,req,res,next) {
	console.error(err.stack);
	res.type('text/plain');
	res.status(500);
	res.send('500!--serve error')
})

app.use((req,res)=>{
	res.status(404);
	res.send('notfound')
})

app.listen(app.get('port'),() => {
	console.log(`now server is running at http://localhost:${app.get('port')};hit ctrl-c to terminate`)
})